package com.chainyoung.component_tmperson.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chainyoung.common.utils.StringUtil;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.entity.WalletProfiRecord;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class WalletFianancingProfitAdapter extends BaseQuickAdapter<WalletProfiRecord, BaseViewHolder> {

    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public WalletFianancingProfitAdapter(@Nullable List<WalletProfiRecord> data) {
        super(R.layout.layout_hdwallet_transaction_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WalletProfiRecord item) {

        ((ImageView) helper.getView(R.id.iv_type)).setImageResource(item.getType().equals("1") ? R.mipmap.ic_type_recieve : R.mipmap.ic_type_send);

        helper.setText(R.id.tv_type, item.getType().equals("1") ? "转入" : item.getType().equals("2") ? "转出" : "收益");
        helper.setText(R.id.tv_addr, item.getType().equals("1") ? "来自支付账户" : "来自增益账户");
        String extraStr = item.getType().equals("1") ? "+" : item.getType().equals("2") ? "-" : "";
        helper.setText(R.id.tv_real_num, extraStr + StringUtil.subZeroAndDot(item.getSum()) + item.getCoin_name().toUpperCase());
        helper.setText(R.id.tv_time, sd.format(new Date(item.getAddtime() * 1000)));


    }


}
